Release 10.1A: OpenEdge Development:
Programming Interfaces
4GL for programming sockets
Table 17–1 lists the 4GL elements that are either valid only for working with sockets or have special application in socket programming. The remaining sections in this chapter explain how to use these elements.
Table 17–1: 4GL for programming sockets 4GL element Description AnINTEGERattribute on the socket object handle that returns the number of bytes read during the last invocation of the socketREAD( )method. If the lastREAD( )method call on the socket failed, this attribute returns 0. AnINTEGERattribute on the socket object handle that returns the number of bytes written during the last invocation of the socketWRITE( )method. If the lastWRITE( )method call on the socket failed, this attribute returns 0. An event received on a server socket object handle that indicates that a socket client is trying to connect. This event, if handled by an I/O-blocking orPROCESS EVENTSstatement, executes anyCONNECTevent procedure defined for the server socket object. You can use this event procedure to obtain the socket object with which the client is communicating. A method on the socket object handle that connects a socket handle to a specified TCP/IP port on a specified host. A method on the socket object handle that indicates if a socket handle is currently connected to a port. A statement that creates a server socket object with all attributes set to their default values, and stores its handle in aHANDLEvariable. A statement that creates a socket object with all attributes set to their default values and stores its handle in aHANDLEvariable. A statement that defines the singleINPUTparameter to theCONNECTevent procedure (specified using theSET-CONNECT-PROCEDURE( )method). This parameter returns the handle to the socket object created when a socket server receives aCONNECTevent, and which the socket server uses to communicate with the corresponding socket client. A statement that you can use to delete a handle, including socket and server socket object handles. To delete a connected socket object, you must first disconnect it using theDISCONNECT( )method. To delete a server socket object enabled to listen for connections, you must first disable it using theDISABLE-CONNECTIONS( )method. A method on the server socket object handle that indicates that new connections are no longer accepted on the server socket. A method on the socket object handle that terminates the connection between the socket object and the port to which it is connected. A method on the server socket object handle that specifies the TCP/IP port that Progress uses to listen for new connections. Once called, Progress automatically listens for and accepts new connections on the specified port.ENABLE-CONNECTIONS()also lets you specify the length of the pending-connection queue. AHANDLEattribute on theSESSIONobject handle that returns the handle to the first entry in the chain of server socket handles for the session. Note that you can have only one server socket object in the list enabled to listen for events at one time. AHANDLEattribute on theSESSIONobject handle that returns the handle to the first entry in the chain of socket handles for the session. A method on the socket object handle that indicates the number of bytes available for reading from the socket. A method on the socket object handle that returns the specified TCP socket option. Progress supports the following options:For more information on these options, see the OpenEdge Development: Progress 4GL Reference and your TCP documentation. AHANDLEattribute on theSESSIONobject handle that returns the handle to the last entry in the chain of server socket handles for the session. Note that you can have only one server socket object in the list enabled to listen for events at one time. AHANDLEattribute on theSESSIONobject handle that returns the handle to the last entry in the chain of socket handles for the session. ACHARACTERattribute on the socket object handle that returns the IP address on the local machine where the socket object is connected. AnINTEGERattribute on the socket object handle that returns the local port number of the socket object. AHANDLEattribute on the socket and server socket object handle that returns the next entry in the list of socket or server socket handles created for the current OpenEdge session. The Progress data type used by the socket handleREAD( )andWRITE( )methods to read and write data on a socket. AMEMPTRexpression defines a memory region whose size you must allocate in bytes.MEMPTRfunctions and statements allow you to read and write data between most other Progress data types and the specified memory region. For more information on theMEMPTRdata type, see Chapter 8, " Introduction to External Program Interfaces." AHANDLEattribute on the socket and server socket object handle that returns the previous entry in the list of socket or server socket handles created for the current OpenEdge session. A statement that you can use to handle any pendingCONNECTorREAD-RESPONSEevents. You can also use any I/O-blocking statement, such as theWAIT-FORstatement. A method on the socket object handle that reads data from the specified socket. The method specifies theMEMPTRmemory region and byte position within the region to store the data, a number of bytes to read (and store) from the socket, and a read mode. The read mode indicates if the exact specified number of bytes must be read or up to the specified number of bytes can be read. An event received on a socket object handle indicating that data is waiting on the socket to be read. This event, if handled by an I/O-blocking orPROCESS EVENTSstatement, executes anyREAD-RESPONSEevent procedure defined for the socket object. You can use this event procedure if you want to read data from the socket in an event-driven manner.1 ACHARACTERattribute on the socket object handle that returns the IP address of the remote machine with which a connected socket object is communicating. AnINTEGERattribute on the socket object handle that returns the number of the port on the remote machine with which a connected socket object is communicating. A system handle that returns the handle of the object on which an event is handled in the context of an event procedure. In aCONNECTevent procedure, this is the handle to the server socket that is responding to aCONNECTevent. In aREAD-RESPONSEevent procedure, this is the handle to the socket that is responding to aREAD-RESPONSEevent. ALOGICALattribute on the socket and server socket object handle that indicates whether the object can receive events. Set toTRUE(receive events) by default. A handle to a server socket object. This object allows you to listen for and accept TCP/IP connections on a given port. A method on the server socket object handle that specifies the name of an internal procedure (CONNECT event procedure) to invoke when aCONNECTevent occurs. A method on the socket object handle that specifies the name of an internal procedure (READ-RESPONSE event procedure) to invoke when aREAD-RESPONSEevent occurs. Socket object handle A handle to a socket object. This object allows you to read or write data on a TCP/IP socket and to perform other TCP/IP socket actions. A method on the socket object handle that sets the specified TCP socket option. Progress supports the following options:For more information on these options, see the OpenEdge Development: Progress 4GL Reference and your TCP documentation. ACHARACTERattribute on the socket object handle that returns the SSL server’s X.500 Subject name field after any SSL session has been established. ACHARACTERattribute on the socket and server socket object handle that returns the handle type, which isSERVER-SOCKETfor a server socket handle andSOCKETfor a socket handle. A statement that you can use to handle any pendingCONNECTorREAD-RESPONSEevents. You can also usePROCESS EVENTSor any other I/O-blocking statement, such as thePROMPT-FORstatement, to handle the events. When aCONNECTorREAD-RESPONSEevent occurs in the context of these statements, anyCONNECTorREAD-RESPONSEevent procedure specified for the corresponding handle is executed. A method on the socket object handle that writes data to the specified socket. The method specifies theMEMPTRmemory region and byte position within the region from which to write the data, as well as the number of bytes to write from the region.
1A socket handle receives aREAD-RESPONSEevent under the same conditions that cause the TCP/IP select function to indicate that a socket is ready to receive results. However, in the 4GL, you must read data on the socket to continue to receive the event. For more information, see the "Data detection using the event-driven model" section.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |